package com.ganzalang.gmall.designstrategy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @description: 折扣计算工厂选择器
 * @author: ganzalang
 */
@Getter
@AllArgsConstructor
public enum DiscountTypeEnum {
    /**
     * 默认无折扣
     */
    DEFAULT(0, "defaultDiscountCalculator"),
    /**
     * 满件折扣
     */
    FULL_PIECE_DISCOUNT(1, "fullPieceDiscountCalculator"),
    /**
     * 买N件第N+1件打折
     */
    MULTI_DISCOUNT(2, "multiDiscountCalculator");




    private Integer type;
    private String beanName;

    public static DiscountTypeEnum getByType(Integer type){
        for (DiscountTypeEnum value : DiscountTypeEnum.values()) {
            if(value.getType().equals(type)){
                return value;
            }
        }
        return DEFAULT;
    }
}
